@if !%_echo% == ! @echo off
set CONFIG=Debug
if NOT "%1" == "" set CONFIG=%1

set VSDir=%HOMEDRIVE%%HOMEPATH%\My Documents\Visual Studio 2005
call :InstallAddin

set VSDir=%HOMEDRIVE%%HOMEPATH%\My Documents\Visual Studio Codename Orcas
call :InstallAddin

set VSDir=%HOMEDRIVE%%HOMEPATH%\My Documents\Visual Studio 2008
call :InstallAddin

set VSDir=%HOMEDRIVE%%HOMEPATH%\Documents\Visual Studio 2005
call :InstallAddin

set VSDir=%HOMEDRIVE%%HOMEPATH%\Documents\Visual Studio Codename Orcas
call :InstallAddin

set VSDir=%HOMEDRIVE%%HOMEPATH%\Documents\Visual Studio 2008
call :InstallAddin

goto :EOF

:InstallAddin
	if NOT EXIST "%VSDir%" (
		goto :EOF
	)
	set Addin=%VSDir%\addins
	if NOT EXIST "%Addin%" (
		mkdir "%Addin%"
	)
	del /f "%Addin%\HyperAddin.*"  1>NUL 2>&1
	if EXIST "%Addin%\HyperAddin.dll.1" ( move /y "%Addin%\HyperAddin.dll.1" "%Addin%\HyperAddin.dll.2" )
	if EXIST "%Addin%\HyperAddin.dll" ( move /y "%Addin%\HyperAddin.dll" "%Addin%\HyperAddin.dll.1" )
	if EXIST "%Addin%\HyperAddin.pdb" ( move /y "%Addin%\HyperAddin.pdb" "%Addin%\HyperAddin.pdb.1" )

	if EXIST "%Addin%\HyperAddin.dll" (
		echo.Could not delete %Addin%\HyperAddin.dll
		exit 1
	)

	echo.Updating VS in %Addin%
	echo.copy "%~dp0bin\%CONFIG%\HyperAddin.*" "%AddIn%"
	copy "%~dp0bin\%CONFIG%\HyperAddin.*" "%AddIn%"
	goto :EOF

